home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 25 / CU Amiga Magazine's Super CD-ROM 25 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-08].iso / CUCD / Programming / buttonbase / bignewbuttontest.e < prev    next >
Text File  |  1998-06-05  |  8KB  |  178 lines

  1. /*
  2.    Name:      bignewbuttontest.e
  3.    About:     Demo of newbutton and newimagebutton plugins
  4.    Version:   $VER: bignewbuttontest.e 1.0 (5.6.98)
  5.    Author:    Copyright © 1998 Victor Ducedre
  6.  
  7.    A brief note:  This was thrown together from Jason's demos for the button
  8.    and imagebutton plugins for button.library.
  9.    This demonstrates different frame types, keyboard support, sizing by both
  10.    image size or supplied attributes, alternate images for selected buttons,
  11.    as well as toggle-selected and push-on-only buttons.
  12.  
  13. */
  14. OPT LARGE
  15.  
  16. MODULE 'tools/easygui', 'tools/exceptions', 'tools/copylist',
  17.        'intuition/intuition', 'intuition/gadgetclass', 'utility',
  18.        'plugins/buttonbase', 'gadgets/buttonclass',
  19.        'plugins/newimagebutton', 'plugins/newbutton'
  20.  
  21. DEF nb2=NIL:PTR TO newbutton, nib2=NIL:PTR TO newimagebutton
  22.  
  23. PROC main() HANDLE
  24. DEF nb1=NIL:PTR TO newbutton, nb3=NIL:PTR TO newbutton, nbp=NIL:PTR TO newbutton,
  25.     nib1=NIL:PTR TO newimagebutton, nib3=NIL:PTR TO newimagebutton,
  26.     nibp=NIL:PTR TO newimagebutton,
  27.     img1, img2, img3, pp1, pp2,
  28.     d1=NIL, d2=NIL, d3=NIL, d4=NIL, d5=NIL
  29.  
  30.   img1:=[0,0,22,22,3,
  31.          d1:=copyListToChip([   /* Plane 0 */
  32.                              $00000000,$00000000,$00000000,$00000000,
  33.                              $00FC0000,$00060000,$00058000,$0404C000,
  34.                              $0407E000,$04006000,$04006000,$04006000,
  35.                              $04006000,$04006000,$04006000,$04006000,
  36.                              $04006000,$04006000,$04006000,$07FFE000,
  37.                              $01FFE000,$00000000,
  38.                               /* Plane 1 */
  39.                              $00000000,$02000000,$0A800000,$07000000,
  40.                              $38C00000,$07F80000,$0BFA8000,$07FB4000,
  41.                              $07F82000,$07FFA000,$07FFA000,$07FFA000,
  42.                              $03FFA000,$03FFA000,$03FFA000,$03FFA000,
  43.                              $03FFA000,$03FFA000,$03FFA000,$00002000,
  44.                              $01FFE000,$00000000,
  45.                               /* Plane 2 */
  46.                              $00000000,$00000000,$00000000,$00000000,
  47.                              $00C00000,$00000000,$00008000,$04004000,
  48.                              $04002000,$04002000,$04002000,$04002000,
  49.                              $00002000,$00002000,$00002000,$00002000,
  50.                              $00002000,$00002000,$00002000,$00002000,
  51.                              $01FFE000,$00000000]),
  52.          $0007,0,NIL]:image
  53.   img2:=[0,0,22,22,3,
  54.          d2:=copyListToChip([   /* Plane 0 */
  55.                              $00000000,$00007000,$0003F000,$000FF000,
  56.                              $001FF800,$000FF800,$0007F800,$1E0FF000,
  57.                              $21DFF000,$40FFF000,$407FF000,$40FB2000,
  58.                              $5FFF8000,$50008000,$7000E000,$6000C000,
  59.                              $60018000,$60018000,$40010000,$7FFE0000,
  60.                              $00000000,$00000000,
  61.                               /* Plane 1 */
  62.                              $00000000,$00004000,$00022000,$0001E000,
  63.                              $0017E800,$000BE800,$0003D800,$0007D000,
  64.                              $1ECE5000,$3F1DB000,$3FB9F000,$3F752000,
  65.                              $20000000,$2FFF0000,$3FFF6000,$1FFF4000,
  66.                              $1FFF8000,$3FFE8000,$3FFE0000,$00000000,
  67.                              $00000000,$00000000,
  68.                               /* Plane 2 */
  69.                              $00000000,$00004000,$00020000,$00000000,
  70.                              $00100800,$00080800,$00001800,$00001000,
  71.                              $1EC01000,$3F01B000,$3F81F000,$3F052000,
  72.                              $20000000,$25550000,$3AAA6000,$15554000,
  73.                              $0AAB8000,$35548000,$2AAA0000,$00000000,
  74.                              $00000000,$00000000]),
  75.          $0007,0,NIL]:image
  76.   img3:=[0,0,22,22,3,
  77.          d3:=copyListToChip([   /* Plane 0 */
  78.                              $00000000,$10000000,$3C000000,$7E000000,
  79.                              $3F000000,$1FB00000,$0FF00000,$07FC0000,
  80.                              $07FC0000,$0BFC0000,$17FF8000,$17F8C000,
  81.                              $11F8C000,$17FFE000,$14002000,$1C003800,
  82.                              $18003000,$18006000,$18006000,$10004000,
  83.                              $1FFF8000,$00000000,
  84.                               /* Plane 1 */
  85.                              $00000000,$00000000,$14000000,$3A000000,
  86.                              $1D000000,$0E900000,$07200000,$03EC0000,
  87.                              $01EC0000,$05F40000,$0BF00000,$08F74000,
  88.                              $0F374000,$08000000,$0BFFC000,$0FFFD800,
  89.                              $07FFD000,$07FFE000,$0FFFA000,$0FFF8000,
  90.                              $00000000,$00000000,
  91.                               /* Plane 2 */
  92.                              $00000000,$00000000,$04000000,$02000000,
  93.                              $01000000,$00900000,$00000000,$000C0000,
  94.                              $000C0000,$04040000,$08000000,$08074000,
  95.                              $0F274000,$08000000,$09554000,$0EAA9800,
  96.                              $05555000,$02AAE000,$0D552000,$0AAA8000,
  97.                              $00000000,$00000000]),
  98.          $0007,0,NIL]:image
  99.   pp1:=[0,0,22,7,2,
  100.         d4:=copyListToChip([$00030000, $0003C000, $0003F000, $0003FC00,
  101.                         $0003F000, $0003C000, $00030000,
  102.                         $E3800000, $E3800000, $E3800000, $E3800000,
  103.                         $E3800000, $E3800000, $E3800000]),
  104.         $0003, 0, NIL]:image
  105.   pp2:=[0,0,22,7,2,
  106.         d5:=copyListToChip([$E3800000, $E3800000, $E3800000, $E3800000,
  107.                         $E3800000, $E3800000, $E3800000,
  108.                         $00030000, $0003C000, $0003F000, $0003FC00,
  109.                         $0003F000, $0003C000, $00030000]),
  110.         $0003, 0, NIL]:image
  111.  
  112.   IF utilitybase:=OpenLibrary('utility.library', 37)
  113.  
  114.   NEW nb1.button([NB_TEXT, '_Toggle', NB_TOGGLE, TRUE, NIL])
  115.   NEW nb2.button([NB_TEXT, '_Push', NB_PUSH, TRUE, NIL])
  116.   NEW nb3.button([NB_TEXT, '<- _Reset', NIL])
  117.   NEW nbp.button([NB_TEXT, 'Paused', NB_TOGGLE, TRUE])
  118.  
  119.   NEW nib1.button([NIB_IMAGE, img1, NB_TOGGLE, TRUE, NB_FRAMETYPE, BATT_THINFRAME, NIL])
  120.   NEW nib2.button([NIB_IMAGE, img2, NB_PUSH, TRUE, NB_FRAMETYPE, BATT_THINFRAME, NIL])
  121.   NEW nib3.button([NIB_IMAGE, img3, NB_FRAMETYPE, BATT_THINFRAME, NIL])
  122.   NEW nibp.button([NIB_IMAGE, pp1, NIB_SELECTRENDER, pp2, NB_TOGGLE, TRUE,
  123.                    NIB_WIDTH, 30, NIB_HEIGHT, 22,
  124.                    NB_FRAMETYPE, BATT_THINFRAME, NIL])
  125.  
  126.   easyguiA('BOOPSI in EasyGUI!',
  127.     [ROWS,
  128.       [TEXT,'Text Buttons (with key support)',NIL,FALSE,5],
  129.       [COLS,
  130.         [NEWBUTTON,{buttonaction1}, nb1],
  131.         [NEWBUTTON,{buttonaction1}, nb2],
  132.         [NEWBUTTON,{buttonaction2}, nb3],
  133.         [NEWBUTTON,{buttonaction4}, nbp]
  134.       ],
  135.       [SBUTTON,{toggle_enabled},'Toggle Enabled',nbp],
  136.       [BAR],
  137.       [TEXT,'Image Buttons (thin frames)',NIL,FALSE,5],
  138.       [COLS,
  139.         [NEWIMAGEBUTTON,{buttonaction1}, nib1],
  140.         [NEWIMAGEBUTTON,{buttonaction1}, nib2],
  141.         [NEWIMAGEBUTTON,{buttonaction3}, nib3],
  142.         [NEWIMAGEBUTTON,{buttonaction1}, nibp]
  143.       ],
  144.       [SBUTTON,{toggle_enabled},'Toggle Enabled',nibp]
  145.     ])
  146.   ENDIF
  147. EXCEPT DO
  148.   END nb1,nb2,nb3,nbp, nib1, nib2, nib3, nibp
  149.   Dispose(d1); Dispose(d2); Dispose(d3); Dispose(d4); Dispose(d5)
  150.   IF utilitybase THEN CloseLibrary(utilitybase)
  151.   report_exception()
  152. ENDPROC
  153.  
  154. PROC buttonaction1(i,b:PTR TO buttonbase)
  155.   WriteF('button selected=\d\n', b.get(NB_SELECTED))
  156. ENDPROC
  157.  
  158. PROC buttonaction2(i,b:PTR TO buttonbase)
  159.   WriteF('button selected=\d\n', b.get(NB_SELECTED))
  160.   IF nb2.get(NB_SELECTED) THEN nb2.set(NB_SELECTED, FALSE)
  161. ENDPROC
  162.  
  163. PROC buttonaction3(i,b:PTR TO buttonbase)
  164.   WriteF('button selected=\d\n', b.get(NB_SELECTED))
  165.   IF nib2.get(NB_SELECTED) THEN nib2.set(NB_SELECTED, FALSE)
  166. ENDPROC
  167.  
  168. PROC buttonaction4(i,b:PTR TO newbutton)
  169.   WriteF('button selected=\d\n', b.get(NB_SELECTED))
  170.   b.set(NB_TEXT, IF b.get(NB_SELECTED) THEN 'Play' ELSE 'Paused')
  171. ENDPROC
  172.  
  173. PROC toggle_enabled(b:PTR TO buttonbase,i)
  174.   b.set(NB_DISABLED, b.get(NB_DISABLED)=FALSE)
  175. ENDPROC
  176.  
  177. vers: CHAR 0, '$VER: bignewbuttontest 1.0 (5.6.98)', 0
  178.